package com.salt.exception;

import cn.hutool.core.util.StrUtil;

public class BusinessException extends RuntimeException{
    private static final long serialVersionUID = 3160241586346324994L;

    private Integer code = 500;

    public BusinessException(Throwable cause) {
        super(cause);
    }

    public BusinessException(String message) {
        super(message);
    }
    public BusinessException(String message,Object ... param) {
        super(StrUtil.format(message, param));
    }

    public BusinessException(Integer code,String message) {
        super(message);
        if(code != null){
            this.code = code;
        }
    }

    public static BusinessException from(Integer code,String message){
        return new BusinessException(code,message);
    }
    public static BusinessException from(String message){
        return new BusinessException(null,message);
    }

    public static BusinessException from(String message, Object... strings) {
        return new BusinessException(null, StrUtil.format(message, strings));
    }

    public Integer getCode() {
        return code;
    }
}
